<?php

class Default_IndexController extends Ext_Controller_Action_Front
{
    public function init()
    {
        parent::init();
    }
    
    public function preDispatch()
    {
        parent::preDispatch();
        
        $userId = Ext_Auth_Front::getInstance()->getIdentity();
        $roleId = Ext_User::getInstance()->show($userId)->buildRole()->role->roleId;

        $acl = Ext_Acl::getInstance()->build($roleId);
        if(!$acl->isAllowed($roleId, 'index', 'view')){
            $this->_forward("show-access-denied", "auth", "account");
            return false;
        }
    }

    public function indexAction()
    {
        $tags = array();
        $recommendTagAll = App_Model_DbTable_Recommend_Tag::getInstance()->getAll();
        for($i=0;$i<count($recommendTagAll);$i++)
        {
            $tagId = $recommendTagAll[$i]['tagId'];
            
            $tagOne = App_Model_DbTable_Tags::getInstance()->getRowById($tagId);
            if($tagOne){
                $tags[] = new Ext_Tag_Show($tagOne['id']);
            }
        }
        $this->view->recommendTags = $tags;
        
        $links = App_Model_DbTable_Links::getInstance()->getCount(20);
        $this->view->links = $links;
    }
}

?>